const express = require("express");
const router = express.Router();
const { Student, Roots } = require("../model");

router.get('/rootAdd', (q, s) => {
  new Roots({
    value: '1',
    label: '1',
    children: [
      {
        value: '2',
        label: '2',
        name: '123'
      }
    ],
  }).save();
  s.send('success')
});

router.get('/find', async (q, s) => {
  const doc = await Roots.findOne({ value: '1' });
  console.log(doc.children);
  doc.children.push({
    value: 2,
    label: 2,
  });
  const res = await doc.save();
  s.send(res)
});

module.exports = router;